﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace ExtendBLL
{
    public class StudentOther:LabMS.BLL.Student
    {
        /// <summary>
        /// 判断此学生号是否存在
        /// </summary>
        /// <param name="Student_Code"></param>
        /// <returns></returns>
        public int IsStudentCodeExits(string Student_Code)
        {
            string str = "Student_Code='"+Student_Code+"'";
            LabMS.BLL.Student BS = new LabMS.BLL.Student();
            if (BS.GetModelList(str).Count > 0)
            {
                return -1;//已经存在，不能注册
            }
            else
            {
                return 0;//不存在，可以注册
            }
        }

  static public List<LabMS.Model.Student> DataSettoStudentModule(DataSet ds)
        {
            List<LabMS.Model.Student> modelList = new List<LabMS.Model.Student>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                LabMS.Model.Student model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new LabMS.Model.Student();
                    if (ds.Tables[0].Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(ds.Tables[0].Rows[n]["ID"].ToString());
                    }
                    model.Student_Code = ds.Tables[0].Rows[n]["Student_Code"].ToString();
                    model.Student_Name = ds.Tables[0].Rows[n]["Student_Name"].ToString();
                    model.Student_Pass = ds.Tables[0].Rows[n]["Student_Pass"].ToString();
                    model.Student_Summary = ds.Tables[0].Rows[n]["Student_Summary"].ToString();
                    if (ds.Tables[0].Rows[n]["ClassID"].ToString() != "")
                    {
                        model.ClassID = int.Parse(ds.Tables[0].Rows[n]["ClassID"].ToString());
                    }
                    model.Student_Sex = ds.Tables[0].Rows[n]["Student_Sex"].ToString();
                    if (ds.Tables[0].Rows[n]["Student_Pro"].ToString() != "")
                    {
                        model.Student_Pro = int.Parse(ds.Tables[0].Rows[n]["Student_Pro"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["Student_EntryDate"].ToString() != "")
                    {
                        model.Student_EntryDate = DateTime.Parse(ds.Tables[0].Rows[n]["Student_EntryDate"].ToString());
                    }
                    model.Student_Grade = ds.Tables[0].Rows[n]["Student_Grade"].ToString();
                    if (ds.Tables[0].Rows[n]["Student_Photo"].ToString() != "")
                    {
                        model.Student_Photo = (byte[])ds.Tables[0].Rows[n]["Student_Photo"];
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }
    }
}
